//
//  PopUpView.m
//  Runone
//
//  Created by runone02 on 16/8/17.
//  Copyright © 2016年 runone. All rights reserved.
//

#import "PopUpView.h"
#import "UIView+Addition.h"

@interface PopUpView ()
@end

@implementation PopUpView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        
    }
    return self;
}


+ (instancetype)menu
{
    return [[self alloc] init];
}

- (void)setContent:(UIView *)content
{
    _content = content;
    
    // 调整内容的位置
    _content.frame    =CGRectMake(self.bounds.size.width / 2 - content.width / 2 , self.bounds.size.height / 2 - content.height +50, content.width, content.height);

    [self addSubview:_content];
}

- (void)setContentController:(UIViewController *)contentController
{
    _contentController = contentController;
    
    self.content = contentController.view;
}

/**
 *  显示
 */
- (void)show
{
    UIWindow *window = [[UIApplication sharedApplication].windows lastObject];
    [window addSubview:self];
}

/**
 *  销毁
 */
- (void)dismiss
{
    [self removeFromSuperview];
}

//- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
//{
//    [self dismiss];
//}
@end
